package com.wkbb.sports.service.impl;

import com.wkbb.common.base.BaseServiceImpl;
import com.wkbb.common.dto.ResultDTO;
import com.wkbb.sports.dto.*;
import com.wkbb.sports.mapper.HlifeDictMapper;
import com.wkbb.sports.model.HlifeDict;
import com.wkbb.sports.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class DictServiceImpl extends BaseServiceImpl<HlifeDict> implements DictService {

    @Autowired
    private HlifeDictMapper dictMapper;

    @Override
    public ResultDTO<List<DictDto>> getDict(Map<String,Object> params) {
        List<HlifeDict> dictList = dictMapper.getListByMapParams(params);
        List<DictDto> dictDtoList = new ArrayList<>();
        for (HlifeDict hlifeDict : dictList) {
            DictDto dictDto = new DictDto();
            dictDto.setId(hlifeDict.getId());
            dictDto.setDictKey(hlifeDict.getDictKey());
            dictDto.setDictValue(hlifeDict.getDictValue());
            dictDtoList.add(dictDto);
        }
        return new ResultDTO<>(dictDtoList);
    }
}
